package com.hzbank.juc.biased;

import lombok.extern.slf4j.Slf4j;
import org.openjdk.jol.info.ClassLayout;

import java.util.Vector;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @description:
 * @author: libugu@cskaoyan.com
 * @date 2023/12/20 - 18:46
 */
@Slf4j(topic = "lalalalalala")
public class BiasedLock01 {
    static Thread t1,t2,t3;
    public static void main(String[] args) throws InterruptedException {
        Dog dog = new Dog();

        new Thread(()->{
            log.debug(ClassLayout.parseInstance(dog).toPrintable());

            synchronized (dog){
                log.debug(ClassLayout.parseInstance(dog).toPrintable());
            }
            log.debug(ClassLayout.parseInstance(dog).toPrintable());

            synchronized (BiasedLock01.class) {
                BiasedLock01.class.notify();
            }

        },"t1").start();

        new Thread(()->{
            synchronized (BiasedLock01.class) {
                try {
                    BiasedLock01.class.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }


            log.debug(ClassLayout.parseInstance(dog).toPrintable());

            synchronized (dog){
                log.debug(ClassLayout.parseInstance(dog).toPrintable());
            }
            log.debug(ClassLayout.parseInstance(dog).toPrintable());

        },"t2").start();


    }
}
class Dog {
}
